import { useUserStore } from "@/stores";
import axios from "axios";




const instance = axios.create({
  baseURL: import.meta.env.SPORTS_SERVER_BASE_URL,
  timeout: 1000 * 20
})

const userStore = useUserStore()

instance.interceptors.request.use((config) => {


  if (userStore.token) {
    config.headers.Authorization = userStore.token
  }
  return config;
}, (error) => {
  return Promise.reject(error);
});

instance.interceptors.response.use((response) => {

  return response
}, (error) => {
  return Promise.reject(error);
});

export {
  instance as request
};

